package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StUserOpe;
import com.ruoyi.system.service.IStUserOpeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 食堂用户操作Controller
 * 
 * @author ruoyi
 * @date 2024-07-16
 */
@RestController
@RequestMapping("/system/ope")
public class StUserOpeController extends BaseController
{
    @Autowired
    private IStUserOpeService stUserOpeService;

    /**
     * 查询食堂用户操作列表
     */
    @PreAuthorize("@ss.hasPermi('system:ope:list')")
    @GetMapping("/list")
    public TableDataInfo list(StUserOpe stUserOpe)
    {
        startPage();
        List<StUserOpe> list = stUserOpeService.selectStUserOpeList(stUserOpe);
        return getDataTable(list);
    }

    /**
     * 导出食堂用户操作列表
     */
    @PreAuthorize("@ss.hasPermi('system:ope:export')")
    @Log(title = "食堂用户操作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StUserOpe stUserOpe)
    {
        List<StUserOpe> list = stUserOpeService.selectStUserOpeList(stUserOpe);
        ExcelUtil<StUserOpe> util = new ExcelUtil<StUserOpe>(StUserOpe.class);
        util.exportExcel(response, list, "食堂用户操作数据");
    }

    /**
     * 获取食堂用户操作详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ope:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(stUserOpeService.selectStUserOpeById(id));
    }

    /**
     * 新增食堂用户操作
     */
    @PreAuthorize("@ss.hasPermi('system:ope:add')")
    @Log(title = "食堂用户操作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StUserOpe stUserOpe)
    {
        return toAjax(stUserOpeService.insertStUserOpe(stUserOpe));
    }

    /**
     * 修改食堂用户操作
     */
    @PreAuthorize("@ss.hasPermi('system:ope:edit')")
    @Log(title = "食堂用户操作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StUserOpe stUserOpe)
    {
        return toAjax(stUserOpeService.updateStUserOpe(stUserOpe));
    }

    /**
     * 删除食堂用户操作
     */
    @PreAuthorize("@ss.hasPermi('system:ope:remove')")
    @Log(title = "食堂用户操作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(stUserOpeService.deleteStUserOpeByIds(ids));
    }
}
